import { resolve } from 'core-js/fn/promise';
import Vue from 'vue'
import VueRouter from 'vue-router'
// import { resolve } from 'core-js/fn/promise';

Vue.use(VueRouter)

/* -------------------------- 配置环境 -------------------------- */

/* -------------------------- 配置页面 -------------------------- */
const Login = resolve => require(['../views/Login'], resolve);
const Screen = resolve => require(['../views/Screen.vue'], resolve)

const Main = resolve => require(['../views/Main'], resolve);

// const CarPlace = resolve=>require(['../views/CarPlace'],resolve);
const parkingSpace = resolve => require(['../views/ParkingSpace'], resolve);

// 系统
const PersonSetting = resolve => require(['../views/system/PersonSetting'], resolve);
const exportFile = resolve => require(['../views/system/exportFile'], resolve);
const PersonConfig = resolve => require(['../views/system/PersonConfig'], resolve);
const ParkingLotSetting = resolve => require(['../views/system/ParkingLotSetting'], resolve);
const PlateManage = resolve => require(['../views/system/PlateManage'], resolve);
const ChargeSetting = resolve => require(['../views/system/ChargeSetting'], resolve);
const ParkEdit = resolve => require(['../views/system/ParkEdit'], resolve);
const TruckSpaceEdit = resolve => require(['../views/system/TruckSpaceEdit'], resolve);
const responsibility = resolve => require(['../views/system/responsibility'], resolve);
const FestivalSetting = resolve => require(['../views/system/FestivalSetting'], resolve);
const Coupon = resolve => require(['../views/system/Coupon.vue'], resolve);
const MarkeingActivities = resolve => require(['../views/system/MarketingActivities.vue'], resolve);
const MarkeingActivitiesRule = resolve => require(['../views/system/MarketingActivitiesRule.vue'], resolve);
const MarkeingActivitiesCard = resolve => require(['../views/system/MarketingMonthCard.vue'], resolve);
const MarkeingActivitiesCardConfig = resolve => require(['../views/system/MarketingMonthCardConfig.vue'], resolve);
const userGroup = resolve => require(['../views/system/UserGroup.vue'], resolve);
const bindCustomer = resolve => require(['../views/system/BindCustomer.vue'], resolve);
//值班管理
//1、车牌纠正
const ParkingRecord = resolve => require(['../views/onduty/ParkingRecord'], resolve);
const PostManange = resolve => require(['../views/onduty/PostManange'], resolve);
const Locus = resolve => require(['../views/onduty/Locus'], resolve);

//设备管理
const EquipmentManage = resolve => require(['../views/equipment/EquipmentManage'], resolve);
const UpdateService = resolve => require(['../views/equipment/UpdateService'], resolve);
const EquipmentModelManage = resolve => require(['../views/equipment/EquipmentModelManage'], resolve);
const EquipmentVersionManage = resolve => require(['../views/equipment/EquipmentVersionManage'], resolve);
const GuideScreenManage = resolve => require(['../views/equipment/GuideScreenManage'], resolve);
const CameraVideoManage = resolve => require(['../views/equipment/CameraVideoManage'], resolve);

//运营服务
const PatrolFeedback = resolve => require(['../views/operate/PatrolFeedback'], resolve);
const UserManager = resolve => require(['../views/operate/UserManager'], resolve);
const BlacklistManager = resolve => require(['../views/operate/BlacklistManager'], resolve);
const ComplaintManager = resolve => require(['../views/operate/ComplaintManager'], resolve);
const UserFeedBack = resolve => require(['../views/operate/UserFeedBack'], resolve);
const LogManager = resolve => require(['../views/operate/LogManager'], resolve);
const WhiteListManager = resolve => require(['../views/operate/WhiteListManager'], resolve);

//收费管理
const RevenueStatistics = resolve => require(['../views/charge/RevenueStatistics'], resolve);
const ParkingRecord2 = resolve => require(['../views/charge/ParkingRecord'], resolve);
const ArrearsRecord = resolve => require(['../views/charge/ArrearsRecord'], resolve);
const ArrearsStatistics = resolve => require(['../views/charge/ArrearsStatistics'], resolve);
const ArrearsStatisticsOwners = resolve => require(['../views/charge/ArrearsStatisticsOwners'], resolve);
const ChargeDetail = resolve => require(['../views/charge/ChargeDetail'], resolve);
const OrderDetail = resolve => require(['../views/charge/orderDetail'], resolve);
const DaysStatements = resolve => require(['../views/charge/DaysStatements'], resolve);
const DaysStatementsDetail = resolve => require(['../views/charge/DaysStatementsDetail'], resolve);
const WriteOff = resolve => require(['../views/charge/WriteOff'], resolve);
const WriteOffDetail = resolve => require(['../views/charge/WriteOffDetail'], resolve);

const ActivitiesRecharge = resolve => require(['../views/charge/ActivitiesRecharge'], resolve);
const MonthCardRecord = resolve => require(['../views/charge/MarketingMonthCardRecord'], resolve);

//财务管理
const Invoice = resolve => require(['../views/bill/invoice'], resolve);

//巡查管理
const membership = resolve => require(['../views/app/membership'], resolve);
const urgeToPay = resolve => require(['../views/app/urgeToPay'], resolve);
const urgePDAToPay = resolve => require(['../views/app/urgePDAToPay'], resolve);

//调试页面
const DebugView = resolve => require(['../views/Debug'], resolve);
//订单修改
const OrderUpdate = resolve => require(['../views/order/OperationChargeDetail'], resolve);
const RefundReview = resolve => require(['../views/order/RefundReview.vue'], resolve);
const RefundRecord = resolve => require(['../views/order/RefundRecord.vue'], resolve);

const MergeOrderManage = resolve => require(['../views/order/MergeOrderManage'], resolve);

//清分管理
const SortingManagement = resolve => require(['../views/sorting/SortingManagement'], resolve);
const OwnerManagement = resolve => require(['../views/sorting/OwnerManagement'], resolve);
const BatchList = resolve => require(['../views/sorting/BatchList'], resolve);
const ReconciliationVariance = resolve => require(['../views/sorting/ReconciliationVariance'], resolve);

//异常订单管理
const ExceptionOrderManagement = resolve => require(['../views/order/ExceptionOrderManage.vue'], resolve);

const router = new VueRouter({
    routes: [{
            path: "/debug",
            component: DebugView
        },
        {
            path: "/system/PersonSetting",
            component: PersonSetting
        },
        {
            path: "/system/exportFile",
            component: exportFile
        },
        {
            path: "/login",
            component: Login,
        }, {
            path: "/main",
            component: Main
        },
        {
            path: "/Screen",
            component: Screen
        },
        /*系统配置*/
        {
            path: "/system/person",
            component: PersonConfig
        }, {
            path: "/system/parkingLot",
            component: ParkingLotSetting
        }, {
            path: "/system/plateManage",
            component: PlateManage
        }, {
            path: "/system/chargeSetting",
            component: ChargeSetting
        },
        {
            path: "/system/responsibility",
            component: responsibility,
        },
        {
            path: '/system/festivalSetting',
            component: FestivalSetting,
        },
        {
            path: "/carplace",
            component: parkingSpace,
        },
        {
            path: "/system/coupon",
            component: Coupon,
        }, {
            path: "/marketing/getList",
            component: MarkeingActivities,
        }, {
            path: "/marketing/getRuleList",
            component: MarkeingActivitiesRule,
        },{
            path: "/marketing/MonthCardManage",
            component: MarkeingActivitiesCard,
        },{
            path: "/marketing/MonthCardConfig",
            component: MarkeingActivitiesCardConfig,
        },{
            path: "/userGroup/listUserGroup",
            component: userGroup,
        },{
            path: "/userGroup/bindCustomer",
            component: bindCustomer,
        },

        //停车场
        //  {
        //     path: "/parkingSpace",
        //     component: parkingSpace,
        // },
        {
            path: "/system/ParkEdit",
            component: ParkEdit,
        },
        {
            path: "/system/TruckSpaceEdit",
            component: TruckSpaceEdit,
        },
        /*值班管理*/
        {
            path: "/onduty/parkingRecord",
            component: ParkingRecord
        },
        {
            path: "/onduty/postManange",
            component: PostManange
        },
        {
            path: "/onduty/locus",
            component: Locus
        },

        /*设备管理*/
        {
            path: "/equipment/equipmentManage",
            component: EquipmentManage
        }, {
            path: "/equipment/UpdateService",
            component: UpdateService
        }, {
            path: "/equipment/EquipmentModelManage",
            component: EquipmentModelManage
        }, {
            path: "/equipment/EquipmentVersionManage",
            component: EquipmentVersionManage
        },{
            path: "/equipment/GuideScreenManage",
            component: GuideScreenManage
        },{
            path: "/equipment/CameraVideoManage",
            component: CameraVideoManage
        },

        /*运营服务*/
        {
            path: "/operate/PatrolFeedback",
            component: PatrolFeedback
        }, {
            path: "/operate/UserManager",
            component: UserManager
        }, {
            path: "/operate/BlacklistManager",
            component: BlacklistManager
        }, {
            path: "/operate/ComplaintManager",
            component: ComplaintManager
        }, {
            path: "/operate/UserFeedBack",
            component: UserFeedBack
        }, {
            path: "/operate/LogManager",
            component: LogManager
        },{
            path: "/operate/WhiteListManager",
            component:  WhiteListManager
        },
        /*收费管理*/
        {
            path: "/charge/RevenueStatistics",
            component: RevenueStatistics
        },
        {
            path: "/charge/ParkingRecord",
            component: ParkingRecord2
        },
        {
            path: "/charge/ArrearsRecord",
            component: ArrearsRecord
        },
        {
            path: "/charge/ArrearsStatistics",
            component: ArrearsStatistics
        },
        {
            path: "/charge/ArrearsStatisticsOwners",
            component: ArrearsStatisticsOwners
        },
        {
            path: "/charge/orderDateil",
            component: OrderDetail
        },
        {
            path: "/charge/ChargeDetail",
            component: ChargeDetail
        },
        {
            path: "/charge/DaysStatements",
            component: DaysStatements
        },
        {
            path: "/charge/DaysStatementsDetail",
            component: DaysStatementsDetail
        },
        {
            path: "/charge/WriteOffDetail",
            component: WriteOffDetail
        },
        {
            path: "/charge/WriteOff",
            component: WriteOff
        },
        {
            path: "/marketing/activities/rechargeList",
            component: ActivitiesRecharge
        },
        {
            path: "/marking/MonthCardRecord",
            component: MonthCardRecord
        },

        /*财务管理*/
        {
            path: "/bill/invoice",
            component: Invoice
        },
        // 巡查管理
        {
            path: "/app/membership",
            component: membership
        },
        {
            path: "/app/urgeToPay",
            component: urgeToPay
        },
        {
            path: "/app/urgePDAToPay",
            component: urgePDAToPay
        },
        //订单修改
        {
            path: "/order/OperationChargeDetail",
            component: OrderUpdate
        },
        //订单合并
        {
            path: "/mergeOrder/MergeOrderManage",
            component: MergeOrderManage
        },
        {
            path: "/order/RefundReview",
            component: RefundReview
        },
        {
            path: "/order/RefundRecord",
            component: RefundRecord
        },
        
        //清分管理
        {
            path: "/sorting/SortingManagement",
            component: SortingManagement
        },  
        {
            path: "/sorting/OwnerManagement",
            component: OwnerManagement  
        },  
        {
            path: "/sorting/BatchList",
            component: BatchList  
        },  
        {
            path: "/sorting/ReconciliationVariance",
            component: ReconciliationVariance  
        },
        {
            path: "/bill/exceptionOrder",
            component: ExceptionOrderManagement
        }
    ]
})

/* -------------------------- 拦截器 -------------------------- */
router.beforeEach((to, from, next) => {
    let token = localStorage.getItem('userinfo');
    // 1、判断是否登录
    // 2、没登录 - 跳转登录
    if (to.path === '/') {
        token === '' || token === null || token === undefined ? next("/login") : next('/main')
    } else {
        next()
    }
})

export {
    router
}
